package main

import (
	"fmt"
	"net/http"
)

func main() {
	//注册回调函数，该回调会在服务器被访问时，自动被调用
	http.HandleFunc("/test", handler)

	//绑定服务器监听地址
	err := http.ListenAndServe("127.0.0.1:8000", nil)
	if err != nil {
		fmt.Println("ListenAndServe err ", err)
	}
}

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Println(r.Body)
	fmt.Println(r.RemoteAddr)
	fmt.Println(r.RequestURI)
	fmt.Println(r.Cookies())

	w.Write([]byte("foo"))
}
